def Feature():
    print('欢迎来到学员管理系统')
    print('1.添加学员')
    print('2.删除学员')
    print('3.修改学学员信息')
    print('4.查询学员信息')
    print('5.显示所有学员信息')
    print('6.退出系统')
global info #申明全局变量info
info = []   #初始化空字典
def add():
    new_name = input('请输入姓名')
    new_gender = input('请输入性别')
    new_age = input('请输入年龄')
    for i in info:
        if new_name == i['name']:
            print('该用户名已经存在')
            return 
    info_dict = {}
    info_dict['name'] = new_name
    info_dict['gender'] = new_gender
    info_dict['age'] = new_age
    info.append(info_dict)
    print(info)
def info_del():
    find_name = (input('name'))
    for i in info:
        if find_name == i['name']:
            info.remove(i)
            break
    else:
        print('该学员不存在')
    print(info)


def Modify_info():
    xueyuan_name = (input('name'))
    for i in info:
        if xueyuan_name == i['name']:
            i['age'] = input('请输入新的年龄')           
            break
    else:
        print('该学员不存在')
    xuanyuanxingbie = (input('gender'))
    for i in info:
        if xuanyuanxingbie == i['gender']:
            i['gender'] = input('请修改学员性别')
            break
    else:
        print('该学员不存在')
    print(info)



def search_info():
    global info
    ser_name = input("请输入要查找的学生姓名")
    for i in info:
        if ser_name == i["name"]:
            print("您找的学生信息如下：")
            print(f'性别为：{i["gender"]},姓名为：{i["name"]},年龄为：{i["age"]}')
            break
    else:
        print("您查找的学生信息不存在")


def print_all():
    print("姓名\t性别\t年龄")
    for i in info:
        print("%s\t%s\t%s " % (i["name"],i["gender"],i["age"]))
while True:
    Feature()
    num = int(input('请输入你需要执行的功能序号'))
    if num == 1:
        add()
    if num == 2:
        info_del()
    if num == 3:
        Modify_info()
    if num == 4:
        search_info()
    if num == 5:
        print_all()
    elif num == 6:
        exit_info = input("您确定退出吗？yes or no")
        if exit_info == "yes":
            break

        